#include "common.h"
namespace common {
std::vector<int> findAnagrams(std::string s, std::string p) {
    std::vector s_count = std::vector<int>(26, 0);
    std::vector p_count = std::vector<int>(26, 0);
    int s_size = s.size();
    int p_size = p.size();
    std::vector<int> res;
    if (s_size < p_size)
        return res;
    for (int i = 0; i < p_size; i++) {
        s_count[s[i] - 'a'] += 1;
        p_count[p[i] - 'a'] += 1;
    }
    if (s_count == p_count)
        res.push_back(0);
    for (int i = 0; i < s_size - p_size; i++) {
        s_count[s[i] - 'a'] -= 1;
        s_count[s[i + p_size] - 'a'] += 1;
        if (s_count == p_count)
            res.push_back(i + 1);
    }
    return res;
}
} // namespace common
